package com.sixteen.ordering_system.mapper;

import com.sixteen.ordering_system.pojo.Dish;
import com.sixteen.ordering_system.pojo.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author sixteen
 * @since 2022-09-16
 */
@Mapper
@Repository
public interface SysUserMapper extends  BaseMapper<SysUser>{
    /*
     *
     * 通过tel查询用户
     *
     * */
    SysUser selectUserByTel(String tel);

    SysUser userAll();

    /**
     *saveUser(做注册添加用户)
     * selectUname（查询库中是否存在用户名，防止注册用户名重复）
     * selectUser（做登录查询库中是否存在用户名和密码）
     */
    @Insert("insert into sys_user(telephone_number,password) values(#{telephone_number},#{password})")
    int saveUser(@Param("telephone_number") String telephoneNumber, @Param("password") String password);

    @Select("select telephone_number,password from sys_user where telephone_number=#{telephone_number}")
    SysUser selectUname(@Param("telephone_number") String telephoneNumber);

    @Select("select telephone_number,password,sys_user_id from sys_user where telephone_number=#{telephone_number} and password=#{password}")
    SysUser selectUser(@Param("telephone_number") String telephoneNumber,@Param("password") String password);

    List<SysUser>  selectByRemark(@Param("sys_user_id") Integer sysUserId,@Param("remark") String remark);
}
